package question;

import model.CalculatorGraph;
import model.Edge;
import model.Vertex;

public class MainQuestion2 {

	public static void main(String[] args) throws Exception {
		
		graph.Graph g = 
			graph.GraphFactory.createGraph( 
				new java.io.File("./resource/graph-question2.txt") );
		
		Vertex[] v = new Vertex[g.getGraph().length];
		
		for (int i = 0; i < g.getGraph().length; i++) {
			v[i] = new Vertex(i);
			v[i].setEdges( new java.util.LinkedList<Edge>() );
			int x = 0;
			for (Integer info : g.getGraph()[i]) {
				v[i].getEdges().add( new Edge(v[i], new Vertex(info), x++) );				
			}
		}
		
		CalculatorGraph c = new CalculatorGraph( v );
		
		Vertex[] vcaminho = c.menorCaminho(new Vertex(0), new Vertex(25));
		
		String way = "0->";
		for (int i = 0; i < vcaminho.length; i++) {
			String indicator = ( (i + 1) == vcaminho.length ) ? "" : "->";
			way += vcaminho[i] + indicator;
		}
		System.out.println( way );
		System.out.println( "Tamanho: " + (vcaminho.length + 1) );
		
	}	
}
